import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_demo/chapter9-Animation/custom-animation/FadeRoute.dart';

void main() => runApp(MaterialApp(
      home: RouteTestRoute(),
    ));

class TipRoute extends StatelessWidget {
  TipRoute({Key? key, required this.text}) : super(key: key);

  final String text;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('提示'),
      ),
      body: Padding(
          padding: const EdgeInsets.all(18.0),
          child: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(text),
                ElevatedButton(
                  onPressed: () => Navigator.pop(context, '我是返回值'),
                  child: const Text('返回'),
                ),
              ],
            ),
          )),
    );
  }
}

class RouteTestRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('主頁'),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: () async {
            var result = await Navigator.push(
                context,
                //     CupertinoPageRoute(builder: (context) {
                //   return TipRoute(text: '我是提示XXX');
                // })
              FadeRoute(builder: (context) => TipRoute(text: '我是提示页'))
                );
            print("路由返回值: $result");
          },
          child: const Text('打开提示页'),
        ),
      ),
    );
  }
}
